<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>日志管理</title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<link rel="stylesheet" href="${_resources}bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="${_resources}bootstrap/bootstrap-table.min.css" />
<script type="text/javascript" src="${_resources}jquery-ui/jquery-ui-1.10.4.custom.min.js"></script>
<link rel="stylesheet" href="${_resources}jquery-ui/jquery-ui-1.10.4.custom.min.css" />
<script type="text/javascript" src="${_resources}JSON-js-master/json2.js"></script>
<!-- 时间插件 -->
<script type="text/javascript" src="${_resources}datepicker/WdatePicker.js"></script>

<script type="text/javascript">
var menuList;
$(function (){
	//初始化表格
	menuList = $("#menuList").bootstrapTable({
		url : '${_baseUrl}/auditLogController/selectAdminLog?startDate=${startDate}&endDate=${endDate}',
		pagination: true,
		pageList: [5, 10, 20, 50],
  		queryParams: queryParams,
        columns: [{
        	 field: 'checked',
             checkbox: true,
             width: 35,
             cellStyle : function(value, row, index) {
               	 if(row.fileTime != null){
                 	return {css:{'color':'#AAAAAA'}};
    	         }else{
     	        	return {css:{'color':''}}; 
  	             }
       		 } 
         }, {
            field: 'id',
            title: 'id',
            visible:false,
            width: 5
        },{
            field: 'logName',
            title: '日志名称',
            width: 80/* ,
            formatter : function(value, row, index) {
            	var str="";
				str +="<a onClick=\"editFun('"+row.id+"');\">"+value+"</a>";  
				return str;
			} */
        },{
            field: 'logNameType',
            title: '日志名称类型',
            width: 100
        },
        {
            field: 'ipAddress',
            title: 'IP ',
            width: 100
        },
        {
            field: 'operTime',
            title: '操作时间 ',
            width: 130
        },
        {
            field: 'comments',
            title: '详情',
            align: 'left',
            width: 200
        }]
    });
	
	function queryParams(params){
		return {
		    pageSize: params.limit,
		    pageNo: params.pn,
		    sort : params.sort,
		    order : params.order,
		    startTime:$("#startTime").val(),
		    endTime:$("#endTime").val(),
		    auditlogType:$("#auditlogType").val()
	   }
	}
	
	
	//初始化时间
	/* $("#startTime").datepicker();
    $("#endTime").datepicker(); */
	
	
})

function deleteFun(id){
	$("#addSnapshotFun").removeAttr('onClick');
	 var rows= $("#menuList").bootstrapTable('getSelections');
	 for ( var i = 0; i < rows.length; i++) {
			var row = rows[i];
			if(row.fileTime != null){
				layer.msg("请选择未归档的数据");
				$("#addSnapshotFun").attr("onClick","addSnapshotFun()");
				return;
			}
		}
		if(rows.length==0){
			layer.msg("请先选择需要操作的数据");
			$("#addSnapshotFun").attr("onClick","addSnapshotFun()");
		}else{
			var rowsString = JSON.stringify(rows); 
			var path="${_baseUrl}/auditLogController/delete";
			 $.ajax({    
					type: "POST",    
					async: false,    
					url:path,   
					data:{
						"rows":rowsString,
					},    
					dataType:"text",    
					success: function (data) { 
						menuList.bootstrapTable('refresh');
						layer.msg("删除成功",{time:2000},function(){
							$("#addSnapshotFun").attr("onClick","addSnapshotFun()");
						});
					}   
				}); 
		} 
}
function addFun(){
	/*  $("#popIframe").empty();	
		$("#popDiv").dialog({
			title:'添加审计',
			autoOpen: true,
			modal: true,	
			height: 600,
			width: 1000
		});	
		$("#popIframe").attr("width","100%");
		$("#popIframe").attr("height","100%");
		$("#popIframe").attr("src","${_baseUrl}/auditLogController/addPage"); */
		layer.open({
	        type: 2 //Page层类型
	        ,area: ['700px', '350px']
	        ,title: '添加审计'
	        ,shade: 0.3 //遮罩透明度
	        ,maxmin: true //允许全屏最小化
	        ,anim: -1 //0-6的动画形式，-1不开启
	        ,content: "${_baseUrl}/auditLogController/addPage"
	    });
}
function addSnapshotFun(){
	$("#addSnapshotFun").removeAttr('onClick');
	var rows= $("#menuList").bootstrapTable('getSelections');
	for ( var i = 0; i < rows.length; i++) {
		var row = rows[i];
		if(row.fileTime != null){
			layer.msg("请选择未归档的数据");
			$("#addSnapshotFun").attr("onClick","addSnapshotFun()");
			return;
		}
	}
	if(rows.length==0){
		layer.msg("请先选择需要操作的数据");
		$("#addSnapshotFun").attr("onClick","addSnapshotFun()");
	}else{
		var rowsString = JSON.stringify(rows); 
		var path="${_baseUrl}/auditLogController/addSnapshot";
		 $.ajax({    
				type: "POST",    
				async: false,    
				url:path,   
				data:{
					"rows":rowsString,
				},    
				dataType:"text",    
				success: function (data) {
					menuList.bootstrapTable('refresh');
					layer.msg("归档成功",{time:2000},function(){
						$("#addSnapshotFun").attr("onClick","addSnapshotFun()");
					});
				}   
			}); 
	} 
}
function editFun(id){
	/*  $("#popIframe").empty();	
		$("#popDiv").dialog({
			title:'查看详情',
			autoOpen: true,
			modal: true,	
			height: 500,
			width: 800
		});	
		$("#popIframe").attr("width","100%");
		$("#popIframe").attr("height","95%");
		$("#popIframe").attr("src","${_baseUrl}/auditLogController/editPage?id="+id); */
		layer.open({
	        type: 2 //Page层类型
	        ,area: ['700px', '350px']
	        ,title: '查看详情'
	        ,shade: 0.3 //遮罩透明度
	        ,maxmin: true //允许全屏最小化
	        ,anim: -1 //0-6的动画形式，-1不开启
	        ,content: "${_baseUrl}/auditLogController/editPage?id="+id
	    });
}
function exportExcel(){
	var selected = menuList.bootstrapTable('getSelections');
	var ids=[];
	for(var i=0;i<selected.length;i++){
		ids.push(selected[i].id);
	}
	var path= '${_baseUrl}/auditLogController/exportExcel?type=admin&startDate='+$("#startTime").val()+'&endDate='+$("#endTime").val()+"&ids="+ids.join(",");
	window.location.href=path;
}
/* 关闭弹出框 */
function closeWin(){
	//$("#popDiv").dialog('close');
	layer.closeAll();
}
function refreshTable(){
	var startDate = $("#startTime").val();
	var endDate = $("#endTime").val();
	if(endDate < startDate){
		layer.msg("结束时间不能比开始时间早");
		return;
	}
	menuList.bootstrapTable('refresh',{url:'${_baseUrl}/auditLogController/selectAdminLog?startDate='+startDate+'&endDate='+endDate});
}
</script>

</head>
<style type="text/css">
.fixed-table-container{border:0px}
table{border:1px solid #ddd;margin-top: 7px!important;}
.fixed-table-header{height:0px}
</style>
<body>
<div class="submenu">
    <div class="func_header">
        <span title="审计管理 > 系统管理员审计">当前位置 ： <a href="javascript:;"></a>审计管理 > 系统管理员审计</span>
    </div>
    <div class="func_bar">
        <div class="search_container" style="width: 60%;">
		    	<div class="func_time" style="margin-left:0px">
	            	<input type="text" name="user_date" id="startTime" value="" onFocus="WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" placeholder="开始时间"/>
	                <a href="javascript:;" class="func_time_a"></a>
	            </div>
	            <div class="func_time" style="margin-left:10px">
	            	<input type="text" name="user_date" id="endTime" value="" onFocus="WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" placeholder="结束时间"/>
	                <a href="javascript:;" class="func_time_b"></a>
	            </div>
	             <div class="func_time" style="margin-left:10px">
	                  <select style="height:28px!important;width:100px" name="auditlogType" id="auditlogType" onchange="refreshTable();" class="func_select validate[required]" >
                         <option value = "">请选择</option>
                         <option value = "1">未归档</option>
                          <option value = "2">已归档</option>
                      </select>
	            </div>
	            <a class="blue_btn" id="search" href="javascript:refreshTable()" onclick="refreshTable();" style="line-height: 20px;margin-left:10px">搜索</a>
        </div>
        <div class="btn_container">
         <shiro:hasPermission name="auditLogController:addSnapshot_3">
            <a class="blue_btn" id="addSnapshotFun" href="javascript:;" onClick="addSnapshotFun();">归档</a>       
         </shiro:hasPermission>
         <shiro:hasPermission name="auditLogController:delete_3">
            <a class="blue_btn" id="delete" href="javascript:;" onClick="deleteFun();">删除</a>
         </shiro:hasPermission>
            <a class="blue_btn" id="export" href="javascript:;" onClick="exportExcel();">导出</a>
        </div>
    </div>
    <div style="overflow: auto; width:98%;margin: auto;">
    	<table id="menuList" class="table table-bordered table_inline"></table>
    </div>
</div>
<%-- <div class="main_cont">
        	<div class="main_c">
                <div class="current_cont">
                    <div class="fl current_c">
                         当前位置 ： <a href="javascript:;">审计管理</a>  >  <a href="javascript:;">审计管理</a>  >  系统管理员审计
                    </div>            
                    <div class="fr current_j">
                        <ul>
                            <li>
                            	<shiro:hasPermission name="auditLogController:addSnapshot_1">
							       <a id="addSnapshotFun" href="javascript:;" class="current_1" onClick="addSnapshotFun();">归档</a>
							    </shiro:hasPermission>
                            </li>
                            <li>
                            	<shiro:hasPermission name="auditLogController:delete_1">
							       <a href="javascript:;" class="current_5" onClick="deleteFun();">删除</a>
							    </shiro:hasPermission>
                            </li>
                            <li>
							     <a href="javascript:;" class="current_6" onClick="exportExcel();">导出</a>
                            </li>
                            <div class="clear"></div>
                        </ul>
                    </div>
                    <div class="clear"></div>
                </div>
                <div>
                	
                    <div class="fl current_s1" style="width: 615px;margin-top: -8px;">
                   		<dl>
                   			<dt>开始时间:</dt>
                   			<dd><input id="startTime" type="text" value="${startDate }" onFocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" class="input_text current_input"></dd>
                   		</dl>
                   		<dl>
                   			<dt>结束时间:</dt>
                   			<dd><input id="endTime" type="text" value="${endDate }" onFocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" class="input_text current_input"></dd>
                   		</dl>
                   		<select style="margin-top: 10px;" name="auditlogType" id="auditlogType"  class="layout_table_select validate[required]">
                         		<option value = "">请选择</option>
                         		<option value = "1">未归档</option>
                          		<option value = "2">已归档</option>
                        </select>
                    </div>
                    <input name="" value="搜索" onclick="refreshTable();" style="margin-left:10px;margin-top:2px" class="dyi_btna dyi_btnabox dyi_btna1" type="button">
                    <!-- <a class="fl" href="javascript:refreshTable()" style="margin-top: 7px;margin-right: 10px;">查询</a> -->
                </div>
                </div>
        <table id="menuList" class="tab-w-01 tab-w-auto"></table>
        </div>
     <div id="popDiv" style="display: none;">
		<iframe id="popIframe"></iframe>
	</div> --%>
</body>
<script type="text/javascript">
$(".func_time_a").click(function(){
	$("#startTime").focus();
	});
$(".func_time_b").click(function(){
	$("#endTime").focus();
	});
</script>
</html>